import axios from 'axios'
import config from '@/config'

const $ajax = axios.create(config.ajax)
$ajax.interceptors.request.use(request => {
	return request
})

$ajax.interceptors.response.use(response => {
	return response.data
}, error => {
  this.$Message.error(
    {
      message: error.message,
      duration: 1000,
      background: '#FF4444'
    }
  )
})


export default {
	post (url, data) {
		return $ajax.post(url, data)
	},
	get (url, params) {
		return $ajax.get(url, { params })
	}
}
